import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export type DefaultConfig = PowerPartial<EggAppConfig>;

export default (appInfo: EggAppInfo) => {
  const config = {} as DefaultConfig;

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1639705506350_3719';

  // add your config here
  config.middleware = ['reportMiddleware', 'jwt', 'exceptionHandleMiddleware'];

  config.midwayFeature = {
    // true 代表使用 midway logger
    // false 或者为空代表使用 egg-logger
    replaceEggLogger: true,
  };

  config.bodyParser = {
    formLimit: '10mb',
  };

  config.reportMiddleware = {
    ignore: ['/swagger-ui/**'],
  };

  config.jwt = {
    secret:
      'asJ1c2VySWQiOjEsImlhdCI6MTYzOTcyOTgzMiwiZXhwIjoxNjM5ODE2MjMyfQva7fxACNNeDZc9PMLqePyqypypO9Z6XQ-HVR4GVtel0',
    ignore: '/user/login',
    enable: false,
  };

  config.multipart = {
    mode: 'file',
  };

  // config.security = {
  //   csrf: false,
  // };
  return config;
};
